var draftBox = new Vue({
    el: "#addDraft",
    data:
        {
            staffList:'',
            title:'',
            loginUser:'',
            messages: '',
            timer: '2022-10-25 16:08:18',
            ceater:'',
            sender:'',
            receiver:'',
            onlinueMessage:'',
        },
    methods: {
        addDraft() {
        axios({
            method: 'POST',
            url: 'http://localhost:8099/draftBox/add',
            data: {
                "title":draftBox.title,
                "createdTime": draftBox.timer,
                "recevierNo": draftBox.receiver,
            }
        }).then(function (res) {
           alert(res.data)
        }).catch(function (reason) {
            console.log(reason);
        })
        },
        getUser() {
            axios({
                method: 'POST',
                url: 'http://localhost:8099/getUser',
            }).then(function (res) {
                draftBox.loginUser = res.data;
            }).catch(function (reason) {
                console.log(reason);
            })
        },
        getList() {
            axios({
                method: 'POST',
                url: 'http://localhost:8099/getList',
            }).then(function (res) {
                draftBox.staffList = res.data;
            }).catch(function (reason) {
                console.log(reason);
            })
        },
        UpdateTime(){
            var time = new Date();
            var yea = time.getFullYear(); //获取完整的年份(4位,1970-???)
            var mon = time.getMonth() + 1; //获取当前月份(0-11,0代表1月)
            var day = time.getDate(); //获取当前日(1-31)
            var hour = time.getHours(); //获取当前小时数(0-23)
            var minute = time.getMinutes(); //获取当前分钟数(0-59)
            var second = time.getSeconds(); //获取当前秒数(0-59)
            draftBox.timer = yea + "-" + mon + "-" + day + " " + hour + ":" + minute + ":" + second;
        },
    },
    //页面加载完自动执行
    mounted() {
        this.getUser()
        this.timer = setInterval(this.UpdateTime, 50)
    }
});
